#ifndef _bsp_can_h
#define _bsp_can_h

#include "main.h"

#define CAN_EXTEND_ID	1
//#define CAN_STANDER_ID	1

extern uint8_t can_frame_count;
extern can_receive_message_struct receive_message;
extern can_trasnmit_message_struct transmit_message;


#define FIFO_SIZE 128
/* CAN recv fifo struct */
typedef struct
{
	uint8_t head;	/* 可读指针 */
	uint8_t tail;	/* 可写指针 */
	uint16_t size;	/* size = FIFO_SIZE */
	uint8_t rxbuffer[FIFO_SIZE];
} fifo_t;

extern fifo_t can_ring_buffer;


void bsp_can_init(void);
uint8_t can_send_msg(uint32_t id, uint8_t *msg, uint8_t len);
void copy_to_fifo(fifo_t* fifo, const uint8_t *from, uint8_t len);
void copy_from_fifo(uint8_t *buf, fifo_t* fifo, uint8_t len);

#endif
